package com.fr.dialog.core;

import com.fr.base.DefaultValues;
import com.fr.base.FRContext;
import com.fr.base.FRFont;
import com.fr.base.core.GraphHelper;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JTextArea;

public class FRFontPreviewArea extends JTextArea
{
  private String paintText = "Report";
  private FRFont frFont = null;

  public FRFontPreviewArea()
  {
    this.frFont = FRContext.getDefaultValues().getFRFont();
  }

  public FRFontPreviewArea(FRFont paramFRFont)
  {
    setFontObject(paramFRFont);
    repaint();
  }

  public void paintComponent(Graphics paramGraphics)
  {
    Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
    Dimension localDimension = getSize();
    localGraphics2D.setColor(getBackground());
    GraphHelper.fillRect(localGraphics2D, 0.0D, 0.0D, localDimension.width, localDimension.height);
    if (this.frFont == null)
      return;
    FontMetrics localFontMetrics = getFontMetrics(this.frFont);
    localGraphics2D.setColor(this.frFont.getForeground());
    localGraphics2D.setFont(this.frFont);
    int i = (localDimension.width - localFontMetrics.stringWidth(this.paintText)) / 2;
    int j = (localDimension.width + localFontMetrics.stringWidth(this.paintText)) / 2;
    int k = (localDimension.height - localFontMetrics.getHeight()) / 2 + localFontMetrics.getAscent();
    GraphHelper.drawLine(localGraphics2D, 4.0D, k, i - 8, k, 1);
    GraphHelper.drawString(localGraphics2D, this.paintText, i, k);
    GraphHelper.drawLine(localGraphics2D, j + 8, k, localDimension.width - 4, k, 1);
  }

  public FRFont getFontObject()
  {
    return this.frFont;
  }

  public void setFontObject(FRFont paramFRFont)
  {
    this.frFont = paramFRFont;
    repaint();
  }
}